package com.two.common.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
    // 配置swagger
    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .paths(Predicates.not(PathSelectors.regex("/error")))
                .build();
        return docket;
    }

    public ApiInfo apiInfo(){
        Contact DEFAULT_CONTACT = new Contact("汪瑞明", "http://taobao.com", "63@qq.com");
        ApiInfo apiInfo = new ApiInfo("在线文档",
                "这是一个文档",
                "1.0",
                "http://bilibili.com",
                DEFAULT_CONTACT,
                "欣欣科技",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<VendorExtension>());
        return apiInfo;
    }
}
